package com.myblog.demo.service;

import com.myblog.demo.entity.Message;
import com.myblog.demo.mapper.MessageMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageService {
    @Autowired
    private MessageMapper messageMapper;
    // 获取指定的对话记录消息列表
    // 默认获取最近的 30 条
    public List<Message> getMessageListBySessionId(@Param("sessionId") Integer sessionId) {
        return messageMapper.getMessageListBySessionId(sessionId);
    }

    // 新增消息到数据库
    public int addMessage(Message message) {
        return messageMapper.addMessage(message);
    }

}
